<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Request extends WD_Controller {


    /**
     * POSTJSON
     */
	public function postJson(){
        $url = isset($_POST["url"]) ? $_POST["url"] : "";
        $jsonstr = isset($_POST["jsonstr"]) ? $_POST["jsonstr"] : "";
        if($jsonarr = json_decode($jsonstr, true)){
            //echo '<pre>';print_r($jsonarr);
            $context = stream_context_create([
                'http' => [
                    'method' => 'POST',
                    'header' => 'Content-type:application/x-www-form-urlencoded',
                    'content' => http_build_query($jsonarr),
                    'timeout' => 20
                ]
            ]);
            echo file_get_contents($url, false, $context);
        }else{
            exit("所传参数非JSON");
        }
	}

}
